﻿CREATE TABLE [dbo].[User] (
    [UserId]      INT            IDENTITY (1, 1) NOT NULL,
    [UserName]    NVARCHAR (56)  NOT NULL,
    [Email]       NVARCHAR (56)  NOT NULL,
    [FirstName]   NVARCHAR (56)  NULL,
    [MiddleName]  NVARCHAR (56)  NULL,
    [LastName]    NVARCHAR (56)  NULL,
    [PhoneNumber] NVARCHAR (56)  NULL,
    [UserTypeId]  INT            NOT NULL,
    [AddressId]   INT            NULL,
    [EmailID]     NVARCHAR (MAX) NULL,
    [Details]     NVARCHAR (MAX) NULL,
    PRIMARY KEY CLUSTERED ([UserId] ASC),
    CONSTRAINT [FK_Users_Address] FOREIGN KEY ([AddressId]) REFERENCES [dbo].[Address] ([AddressId]),
    CONSTRAINT [FK_Users_UserType] FOREIGN KEY ([UserTypeId]) REFERENCES [dbo].[UserType] ([UserTypeId]),
    UNIQUE NONCLUSTERED ([UserName] ASC),
    CONSTRAINT [UQ__Users__Email] UNIQUE NONCLUSTERED ([Email] ASC)
);

